#ifndef __LOG_HH__
#define __LOG_HH__
#include <iostream>
#include <fstream>
#include <string>
#include <log4cpp/PatternLayout.hh>
#include <log4cpp/RollingFileAppender.hh>
#include <log4cpp/Appender.hh>
#include <log4cpp/OstreamAppender.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/Category.hh>
#include "../HONG.hh"

using namespace log4cpp;
using std::string;

class Log
{
public:
    static Log* createLog(int output);
    static void destroyLog();

    template <class ...Args>
    static void warn(Args ...args){_sub.warn(args...);} 
    template <class ...Args>
    static void error(Args ...args){_sub.error(args...);}
    template <class ...Args>
	static void debug(Args ...args){_sub.debug(args...);}
    template <class ...Args>
    static void info(Args ...args){_sub.info(args...);}
    template <class ...Args>
    static void fatal(Args ...args){_sub.fatal(args...);}
    template <class ...Args>
    static void crit(Args ...args){_sub.crit(args...);}
private:
    Log(int output);
    ~Log();
    void outputConsole();
    void outputFile(const string& file);
    void outputRoll(const string& roll);

private:
    // 输出到屏幕
    PatternLayout *_ptn1 = nullptr; 
    Appender *_appender1 = nullptr;
    // 输出到日志文件
    PatternLayout *_ptn2 = nullptr;
    Appender *_appender2 = nullptr;
    // 输出到回卷文件
    PatternLayout *_ptn3 = nullptr;
    Appender *_appender3 = nullptr;

    static Category& _sub;
    static Log* _instance;
};


#endif